<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    
    <title>Getting started with Git development &mdash; NumPy v1.18 Manual</title>
    
    <link rel="stylesheet" type="text/css" href="../../_static/css/spc-bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../../_static/css/spc-extend.css">
    <link rel="stylesheet" href="../../_static/scipy.css" type="text/css" >
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" >
    <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" >
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '1.18.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  false
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/language_data.js"></script>
    <script type="text/javascript" src="../../_static/js/copybutton.js"></script>
    <link rel="author" title="About these documents" href="../../about.html" >
    <link rel="index" title="Index" href="../../genindex.html" >
    <link rel="search" title="Search" href="../../search.html" >
    <link rel="top" title="NumPy v1.18 Manual" href="../../index.html" >
    <link rel="up" title="Git for development" href="index.html" >
    <link rel="next" title="Git configuration" href="configure_git.html" >
    <link rel="prev" title="Get the local copy of the code" href="following_latest.html" > 
  </head>
  <body>
<div class="container">
  <div class="top-scipy-org-logo-header" style="background-color: #a2bae8;">
    <a href="../../index.html">
      <img border=0 alt="NumPy" src="../../_static/numpy_logo.png"></a>
    </div>
  </div>
</div>


    <div class="container">
      <div class="main">
        
	<div class="row-fluid">
	  <div class="span12">
	    <div class="spc-navbar">
              
    <ul class="nav nav-pills pull-left">
        <li class="active"><a href="https://numpy.org/">NumPy.org</a></li>
        <li class="active"><a href="https://numpy.org/doc">Docs</a></li>
        
        <li class="active"><a href="../../index.html">NumPy v1.18 Manual</a></li>
        

          <li class="active"><a href="../index.html" >Contributing to NumPy</a></li>
          <li class="active"><a href="index.html" accesskey="U">Git for development</a></li> 
    </ul>
              
              
    <ul class="nav nav-pills pull-right">
      <li class="active">
        <a href="../../genindex.html" title="General Index"
           accesskey="I">index</a>
      </li>
      <li class="active">
        <a href="configure_git.html" title="Git configuration"
           accesskey="N">next</a>
      </li>
      <li class="active">
        <a href="following_latest.html" title="Get the local copy of the code"
           accesskey="P">previous</a>
      </li>
    </ul>
              
	    </div>
	  </div>
	</div>
        

	<div class="row-fluid">
      <div class="spc-rightsidebar span3">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Getting started with Git development</a><ul>
<li><a class="reference internal" href="#basic-git-setup">Basic Git setup</a></li>
<li><a class="reference internal" href="#making-your-own-copy-fork-of-numpy">Making your own copy (fork) of NumPy</a><ul>
<li><a class="reference internal" href="#set-up-and-configure-a-github-account">Set up and configure a github account</a></li>
<li><a class="reference internal" href="#create-your-own-forked-copy-of-numpy">Create your own forked copy of NumPy</a></li>
</ul>
</li>
<li><a class="reference internal" href="#set-up-your-fork">Set up your fork</a><ul>
<li><a class="reference internal" href="#overview">Overview</a></li>
<li><a class="reference internal" href="#in-detail">In detail</a><ul>
<li><a class="reference internal" href="#clone-your-fork">Clone your fork</a></li>
<li><a class="reference internal" href="#linking-your-repository-to-the-upstream-repo">Linking your repository to the upstream repo</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="following_latest.html"
                        title="previous chapter">Get the local copy of the code</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="configure_git.html"
                        title="next chapter">Git configuration</a></p>
<div id="searchbox" style="display: none" role="search">
  <h4>Quick search</h4>
    <div>
    <form class="search" action="../../search.html" method="get">
      <input type="text" style="width: inherit;" name="q" />
      <input type="submit" value="search" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
          <div class="span9">
            
        <div class="bodywrapper">
          <div class="body" id="spc-section-body">
            
  <div class="section" id="getting-started-with-git-development">
<h1>Getting started with Git development<a class="headerlink" href="#getting-started-with-git-development" title="Permalink to this headline">¶</a></h1>
<p>This section and the next describe in detail how to set up git for working
with the NumPy source code.  If you have git already set up, skip to
<a class="reference internal" href="../development_workflow.html#development-workflow"><span class="std std-ref">Development workflow</span></a>.</p>
<div class="section" id="basic-git-setup">
<h2>Basic Git setup<a class="headerlink" href="#basic-git-setup" title="Permalink to this headline">¶</a></h2>
<ul>
<li><p><a class="reference external" href="https://docs.scipy.org/doc/scipy/reference/dev/gitwash/gitwash.html#install-git" title="(in SciPy v1.4.1)"><span class="xref std std-ref">install-git</span></a>.</p></li>
<li><p>Introduce yourself to Git:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">config</span> <span class="o">--</span><span class="k">global</span> <span class="n">user</span><span class="o">.</span><span class="n">email</span> <span class="n">you</span><span class="nd">@yourdomain</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">com</span>
<span class="n">git</span> <span class="n">config</span> <span class="o">--</span><span class="k">global</span> <span class="n">user</span><span class="o">.</span><span class="n">name</span> <span class="s2">&quot;Your Name Comes Here&quot;</span>
</pre></div>
</div>
</li>
</ul>
</div>
<div class="section" id="making-your-own-copy-fork-of-numpy">
<span id="forking"></span><h2>Making your own copy (fork) of NumPy<a class="headerlink" href="#making-your-own-copy-fork-of-numpy" title="Permalink to this headline">¶</a></h2>
<p>You need to do this only once.  The instructions here are very similar
to the instructions at <a class="reference external" href="http://help.github.com/forking/">http://help.github.com/forking/</a> - please see that
page for more detail.  We’re repeating some of it here just to give the
specifics for the <a class="reference external" href="https://www.numpy.org">NumPy</a> project, and to suggest some default names.</p>
<div class="section" id="set-up-and-configure-a-github-account">
<span id="id1"></span><h3>Set up and configure a <a class="reference external" href="https://github.com/numpy/numpy">github</a> account<a class="headerlink" href="#set-up-and-configure-a-github-account" title="Permalink to this headline">¶</a></h3>
<p>If you don’t have a <a class="reference external" href="https://github.com/numpy/numpy">github</a> account, go to the <a class="reference external" href="https://github.com/numpy/numpy">github</a> page, and make one.</p>
<p>You then need to configure your account to allow write access - see the
<code class="docutils literal notranslate"><span class="pre">Generating</span> <span class="pre">SSH</span> <span class="pre">keys</span></code> help on <a class="reference external" href="https://help.github.com">github help</a>.</p>
</div>
<div class="section" id="create-your-own-forked-copy-of-numpy">
<h3>Create your own forked copy of <a class="reference external" href="https://www.numpy.org">NumPy</a><a class="headerlink" href="#create-your-own-forked-copy-of-numpy" title="Permalink to this headline">¶</a></h3>
<ol class="arabic">
<li><p>Log into your <a class="reference external" href="https://github.com/numpy/numpy">github</a> account.</p></li>
<li><p>Go to the <a class="reference external" href="https://www.numpy.org">NumPy</a> github home at <a class="reference external" href="https://github.com/numpy/numpy">NumPy github</a>.</p></li>
<li><p>Click on the <em>fork</em> button:</p>
<img alt="../../_images/forking_button.png" src="../../_images/forking_button.png" />
<p>After a short pause, you should find yourself at the home page for
your own forked copy of <a class="reference external" href="https://www.numpy.org">NumPy</a>.</p>
</li>
</ol>
</div>
</div>
<div class="section" id="set-up-your-fork">
<span id="set-up-fork"></span><h2>Set up your fork<a class="headerlink" href="#set-up-your-fork" title="Permalink to this headline">¶</a></h2>
<p>First you follow the instructions for <a class="reference internal" href="#forking"><span class="std std-ref">Making your own copy (fork) of NumPy</span></a>.</p>
<div class="section" id="overview">
<h3>Overview<a class="headerlink" href="#overview" title="Permalink to this headline">¶</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">clone</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">your</span><span class="o">-</span><span class="n">user</span><span class="o">-</span><span class="n">name</span><span class="o">/</span><span class="n">numpy</span><span class="o">.</span><span class="n">git</span>
<span class="n">cd</span> <span class="n">numpy</span>
<span class="n">git</span> <span class="n">remote</span> <span class="n">add</span> <span class="n">upstream</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">numpy</span><span class="o">/</span><span class="n">numpy</span><span class="o">.</span><span class="n">git</span>
</pre></div>
</div>
</div>
<div class="section" id="in-detail">
<h3>In detail<a class="headerlink" href="#in-detail" title="Permalink to this headline">¶</a></h3>
<div class="section" id="clone-your-fork">
<h4>Clone your fork<a class="headerlink" href="#clone-your-fork" title="Permalink to this headline">¶</a></h4>
<ol class="arabic">
<li><p>Clone your fork to the local computer with <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">clone</span>
<span class="pre">https://github.com/your-user-name/numpy.git</span></code></p></li>
<li><p>Investigate.  Change directory to your new repo: <code class="docutils literal notranslate"><span class="pre">cd</span> <span class="pre">numpy</span></code>. Then
<code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">branch</span> <span class="pre">-a</span></code> to show you all branches.  You’ll get something
like:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">*</span> <span class="n">master</span>
<span class="n">remotes</span><span class="o">/</span><span class="n">origin</span><span class="o">/</span><span class="n">master</span>
</pre></div>
</div>
<p>This tells you that you are currently on the <code class="docutils literal notranslate"><span class="pre">master</span></code> branch, and
that you also have a <code class="docutils literal notranslate"><span class="pre">remote</span></code> connection to <code class="docutils literal notranslate"><span class="pre">origin/master</span></code>.
What remote repository is <code class="docutils literal notranslate"><span class="pre">remote/origin</span></code>? Try <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">remote</span> <span class="pre">-v</span></code> to
see the URLs for the remote.  They will point to your <a class="reference external" href="https://github.com/numpy/numpy">github</a> fork.</p>
<p>Now you want to connect to the upstream <a class="reference external" href="https://github.com/numpy/numpy">NumPy github</a> repository, so
you can merge in changes from trunk.</p>
</li>
</ol>
</div>
<div class="section" id="linking-your-repository-to-the-upstream-repo">
<span id="linking-to-upstream"></span><h4>Linking your repository to the upstream repo<a class="headerlink" href="#linking-your-repository-to-the-upstream-repo" title="Permalink to this headline">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">numpy</span>
<span class="n">git</span> <span class="n">remote</span> <span class="n">add</span> <span class="n">upstream</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">numpy</span><span class="o">/</span><span class="n">numpy</span><span class="o">.</span><span class="n">git</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">upstream</span></code> here is just the arbitrary name we’re using to refer to the
main <a class="reference external" href="https://www.numpy.org">NumPy</a> repository at <a class="reference external" href="https://github.com/numpy/numpy">NumPy github</a>.</p>
<p>Just for your own satisfaction, show yourself that you now have a new
‘remote’, with <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">remote</span> <span class="pre">-v</span> <span class="pre">show</span></code>, giving you something like:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">upstream</span>     <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">numpy</span><span class="o">/</span><span class="n">numpy</span><span class="o">.</span><span class="n">git</span> <span class="p">(</span><span class="n">fetch</span><span class="p">)</span>
<span class="n">upstream</span>     <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">numpy</span><span class="o">/</span><span class="n">numpy</span><span class="o">.</span><span class="n">git</span> <span class="p">(</span><span class="n">push</span><span class="p">)</span>
<span class="n">origin</span>       <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">your</span><span class="o">-</span><span class="n">user</span><span class="o">-</span><span class="n">name</span><span class="o">/</span><span class="n">numpy</span><span class="o">.</span><span class="n">git</span> <span class="p">(</span><span class="n">fetch</span><span class="p">)</span>
<span class="n">origin</span>       <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">your</span><span class="o">-</span><span class="n">user</span><span class="o">-</span><span class="n">name</span><span class="o">/</span><span class="n">numpy</span><span class="o">.</span><span class="n">git</span> <span class="p">(</span><span class="n">push</span><span class="p">)</span>
</pre></div>
</div>
<p>To keep in sync with changes in NumPy, you want to set up your repository
so it pulls from <code class="docutils literal notranslate"><span class="pre">upstream</span></code> by default.  This can be done with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">config</span> <span class="n">branch</span><span class="o">.</span><span class="n">master</span><span class="o">.</span><span class="n">remote</span> <span class="n">upstream</span>
<span class="n">git</span> <span class="n">config</span> <span class="n">branch</span><span class="o">.</span><span class="n">master</span><span class="o">.</span><span class="n">merge</span> <span class="n">refs</span><span class="o">/</span><span class="n">heads</span><span class="o">/</span><span class="n">master</span>
</pre></div>
</div>
<p>You may also want to have easy access to all pull requests sent to the
NumPy repository:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">config</span> <span class="o">--</span><span class="n">add</span> <span class="n">remote</span><span class="o">.</span><span class="n">upstream</span><span class="o">.</span><span class="n">fetch</span> <span class="s1">&#39;+refs/pull/*/head:refs/remotes/upstream/pr/*&#39;</span>
</pre></div>
</div>
<p>Your config file should now look something like (from
<code class="docutils literal notranslate"><span class="pre">$</span> <span class="pre">cat</span> <span class="pre">.git/config</span></code>):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">core</span><span class="p">]</span>
        <span class="n">repositoryformatversion</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">filemode</span> <span class="o">=</span> <span class="n">true</span>
        <span class="n">bare</span> <span class="o">=</span> <span class="n">false</span>
        <span class="n">logallrefupdates</span> <span class="o">=</span> <span class="n">true</span>
        <span class="n">ignorecase</span> <span class="o">=</span> <span class="n">true</span>
        <span class="n">precomposeunicode</span> <span class="o">=</span> <span class="n">false</span>
<span class="p">[</span><span class="n">remote</span> <span class="s2">&quot;origin&quot;</span><span class="p">]</span>
        <span class="n">url</span> <span class="o">=</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">your</span><span class="o">-</span><span class="n">user</span><span class="o">-</span><span class="n">name</span><span class="o">/</span><span class="n">numpy</span><span class="o">.</span><span class="n">git</span>
        <span class="n">fetch</span> <span class="o">=</span> <span class="o">+</span><span class="n">refs</span><span class="o">/</span><span class="n">heads</span><span class="o">/*</span><span class="p">:</span><span class="n">refs</span><span class="o">/</span><span class="n">remotes</span><span class="o">/</span><span class="n">origin</span><span class="o">/*</span>
<span class="p">[</span><span class="n">remote</span> <span class="s2">&quot;upstream&quot;</span><span class="p">]</span>
        <span class="n">url</span> <span class="o">=</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">numpy</span><span class="o">/</span><span class="n">numpy</span><span class="o">.</span><span class="n">git</span>
        <span class="n">fetch</span> <span class="o">=</span> <span class="o">+</span><span class="n">refs</span><span class="o">/</span><span class="n">heads</span><span class="o">/*</span><span class="p">:</span><span class="n">refs</span><span class="o">/</span><span class="n">remotes</span><span class="o">/</span><span class="n">upstream</span><span class="o">/*</span>
        <span class="n">fetch</span> <span class="o">=</span> <span class="o">+</span><span class="n">refs</span><span class="o">/</span><span class="n">pull</span><span class="o">/*/</span><span class="n">head</span><span class="p">:</span><span class="n">refs</span><span class="o">/</span><span class="n">remotes</span><span class="o">/</span><span class="n">upstream</span><span class="o">/</span><span class="n">pr</span><span class="o">/*</span>
<span class="p">[</span><span class="n">branch</span> <span class="s2">&quot;master&quot;</span><span class="p">]</span>
        <span class="n">remote</span> <span class="o">=</span> <span class="n">upstream</span>
        <span class="n">merge</span> <span class="o">=</span> <span class="n">refs</span><span class="o">/</span><span class="n">heads</span><span class="o">/</span><span class="n">master</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>


          </div>
        </div>
          </div>
        </div>
      </div>
    </div>

    <div class="container container-navbar-bottom">
      <div class="spc-navbar">
        
      </div>
    </div>
    <div class="container">
    <div class="footer">
    <div class="row-fluid">
    <ul class="inline pull-left">
      <li>
        &copy; Copyright 2008-2019, The SciPy community.
      </li>
      <li>
      Last updated on Feb 20, 2020.
      </li>
      <li>
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 2.4.2.
      </li>
    </ul>
    </div>
    </div>
    </div>
  </body>
</html>